package com.touch.workshop.ui.expgrowth;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import com.touch.util.IntTools;
public class Scale extends JInternalFrame implements InternalFrameListener, KeyListener
{
	private static final long serialVersionUID = 8258851386248463381L;
	
	private JTextField minimum = new JTextField(8);
	private JTextField maximum = new JTextField(8);
	
	public Scale()
	{
		super("EXP Curve Scale", true, true, true, true);
		
		this.setSize(300, 60);
		this.setLayout(new FlowLayout());
		this.addInternalFrameListener(this);		
		
		this.add(new JLabel("Range :"));
		this.add(this.minimum);
		this.add(this.maximum);
		
		this.maximum.addKeyListener(this);
		this.minimum.addKeyListener(this);
		
		this.update();
	}
	public void update()
	{
		this.minimum.setText(Integer.toString(CurveControls.CURVE_MINIMUM));
		this.maximum.setText(Integer.toString(CurveControls.CURVE_MAXIMUM));
	}
	public void setValues()
	{
		CurveControls.CURVE_MINIMUM = (int)IntTools.getValue(this.minimum.getText());
		CurveControls.CURVE_MAXIMUM = (int)IntTools.getValue(this.maximum.getText());		
		CurveControls.update();
	}	
	public void internalFrameActivated(InternalFrameEvent arg0)	{}
	public void internalFrameClosed(InternalFrameEvent arg0) 		{}
	public void internalFrameClosing(InternalFrameEvent arg0) 
	{	
		setValues();
	}
	public void internalFrameDeactivated(InternalFrameEvent arg0) {}
	public void internalFrameDeiconified(InternalFrameEvent arg0) {}
	public void internalFrameIconified(InternalFrameEvent arg0) 	{}
	public void internalFrameOpened(InternalFrameEvent arg0) 
	{
		CurveControls.update();
	}
	public void keyPressed(KeyEvent e) 
	{	
		if(e.getKeyCode() == KeyEvent.VK_ENTER)
		{
			this.setValues();
			this.setVisible(false);
		}
	}
	public void keyReleased(KeyEvent arg0) 			{}
	public void keyTyped(KeyEvent arg0) 			{}	
}
